# CFLAGS表示编译选项，-g表示 生成调试信息，-o0表示优化等级为0，-Wall表示开启所有警告，-Wextra表示开启额外警告，-Werror表示将警告视为错误
# CFLAGS := -g -o0 -Wall -Wextra -Werror
CC := gcc
CFLAGS := -g -o0 -Wall
log := thirdparty/log/log.h thirdparty/log/log.c
json := thirdparty/cJSON/cJSON.h thirdparty/cJSON/cJSON.c
app_common := app/app_common.h app/app_common.c
app_message:=app/app_message.h app/app_message.c
app_mqtt:=app/app_mqtt.h app/app_mqtt.c
# $^: 依赖列表
# $@: 目标名
# -I: 给gcc配置包含的查看路径
# -l: 指定用到的下载的库
# $< - first prerequisite 


log_test  : $(log) test/test_log.c
	-gcc $^ -o $@ -I thirdparty
	-./$@
	rm $@

json_test : $(log) $(json) test/test_cJSON.c
	-gcc $^ -o $@ -I thirdparty
	-./$@
	rm $@

json_test_debug : $(log) $(json) test/test_cJSON.c
	-gcc $(CFLAGS) $^ -o $@ -I thirdparty
#	-./$@
#	rm $@

app_common_test: test/test_app_common.c $(app_common) $(log)
	-$(CC)  $^ -o $@ -I app -I thirdparty
	-./$@
	-rm $@


app_message_test: test/test_app_message.c $(app_message) $(app_common) $(log) $(json)
	-$(CC) $^ -o $@ -Iapp -Ithirdparty
	-./$@
	-rm $@

mqtt_test: test/test_mqtt.c
	-$(CC) $^ -o $@ -lpaho-mqtt3c
	-./$@
	-rm $@

	
app_mqtt_test: test/test_app_mqtt.c $(app_mqtt) $(log)
	-$(CC) $^ -o $@ -Iapp -Ithirdparty -lpaho-mqtt3c
	-./$@
	-rm $@
